package com.quanyan.comment.reqeust;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/30.
 */
public class ReqUserCollectQuery implements Serializable{

    private String systemCode;

    private String businessCode;

    /**
     * 用户Id
     */
    @NotNull(message = "userId不能为空！")
    private Integer userId;

    /**
     * 分页参数
     */
    private Integer pageNum ;

    /**
     * 每页的大小
     */
    private Integer pageSize;

    private Integer businessId;



    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageNum() {
        if(this.pageNum == null)
            this.pageNum = 0;

        if(this.pageNum <= 0) {
            this.pageNum = 0;
        }
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        if(this.pageSize == null)
            this.pageSize = 10 ;

        return pageSize;
    }


    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getSystemCode() {
        return systemCode;
    }

    public void setSystemCode(String systemCode) {
        this.systemCode = systemCode;
    }

    public String getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(String businessCode) {
        this.businessCode = businessCode;
    }

    @Override
    public String toString() {
        return "ReqUserCollectQuery{" +
                "systemCode='" + systemCode + '\'' +
                ", businessCode='" + businessCode + '\'' +
                ", userId=" + userId +
                ", pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", businessId=" + businessId +
                '}';
    }

    public Integer getBusinessId() {
        return businessId;
    }

    public void setBusinessId(Integer businessId) {
        this.businessId = businessId;
    }

    public Map<String,Object> toMap(){
        Map<String,Object> map = new HashMap<String, Object>();

        if(StringUtils.isNotBlank(this.businessCode))
            map.put("businessCode",businessCode);

        if(StringUtils.isNotBlank(this.systemCode))
            map.put("systemCode",systemCode);

        if(this.userId != null)
            map.put("userId",this.userId);

        if(this.businessId != null )
            map.put("businessId",this.businessId);

        return  map;
    }
}
